﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Ue.Core.FileSystems;

namespace Ue.Framework.Tests.Core.FileSystems
{
    /// <summary>
    /// FolderRoot 的摘要说明
    /// </summary>
    [TestClass]
    public class FolderRootTests
    {
        [TestMethod]
        public void DefaultFolderRoot()
        {
            FolderRoot root = new FolderRoot();

            Assert.AreEqual("/",root.RootPath);
            Assert.AreEqual(Environment.CurrentDirectory,root.RootPhysicalPath);
        }

        [TestMethod]
        public void PhysicalPath()
        {
            FolderRoot root = new FolderRoot("D:\\Directory1\\ChildDirectory");

            Assert.AreEqual(string.Empty, root.RootPath);
            Assert.AreEqual("D:\\Directory1\\ChildDirectory", root.RootPhysicalPath);
       
        }

        [TestMethod]
        public void AbsolutePath()
        {
            FolderRoot root = new FolderRoot("/Directory1/ChildDirectory");

            Assert.AreEqual("/Directory1/ChildDirectory", root.RootPath);
            Assert.AreEqual(string.Format(Environment.CurrentDirectory + "\\Directory1\\ChildDirectory"), root.RootPhysicalPath);
        }

        [TestMethod]
        public void RelativelyPath()
        {
            FolderRoot root = new FolderRoot("Directory1/ChildDirectory");

            Assert.AreEqual("/Directory1/ChildDirectory", root.RootPath);
            Assert.AreEqual(string.Format(Environment.CurrentDirectory + "\\Directory1\\ChildDirectory"), root.RootPhysicalPath);
        }

        [TestMethod]
        public void HasEndSeparatorChar()
        {
            FolderRoot root = new FolderRoot("/Directory1/ChildDirectory/");

            Assert.AreEqual("/Directory1/ChildDirectory", root.RootPath);
            Assert.AreEqual(string.Format(Environment.CurrentDirectory + "\\Directory1\\ChildDirectory"), root.RootPhysicalPath);
        }

        [TestMethod]
        public void PhysicalSeparatorChar()
        {
            FolderRoot root = new FolderRoot("\\Directory1\\ChildDirectory\\");

            Assert.AreEqual("/Directory1/ChildDirectory", root.RootPath);
            Assert.AreEqual(string.Format(Environment.CurrentDirectory + "\\Directory1\\ChildDirectory"), root.RootPhysicalPath);
        }
    }
}
